Fix all remaining issues: CFF refactor, junkcode cleanup, naming, constants, func2rva - #21
Merged
Merged
Conversation
Issue #5 — obfuscatecff refactoring: - Remove `using namespace asmjit;` from header, qualify all types - Move ZydisFormatter/ZydisDecoder from file scope to class members - Remove dead private forward declarations of instruction_t/function_t - Pass create_functions param by const-reference (was copying entire vector) - Use const auto& in loop iterations (was copying each element) - Replace visited_rvas vector with unordered_set (O(1) vs O(n) lookup) - Add const to get_added_size() Issue #6 — cfflattening fixes: - Fix is_first_instruction: set to true on push_rax (was always false) - Add null-check after find_if for last_inst (was UB on end()) Issue #7 — junkcode refactoring: - Extract duplicated junk patching loops into patch_junk_region() helper - Replace silent data corruption on INT32 overflow with warning + skip - Remove all dead `std::cout << ""` output statements Issue #10 — naming consistency: - Rename ctfflattening → cff_flattening across all files - Qualify asmjit types with namespace prefix - Update REG_PAIR macro to use asmjit::x86:: Issue #12 — func2rva refactoring: - Extract duplicated display code into display_function_table() method - Replace static empty_list with throw on uninitialized access Issue #15 — constants: - Create constants.h with all named constants (PE, CFF, junk, PDB) - Add to vcxproj and vcxproj.filters Issue #16 — junk instruction pool: - Make junk instruction vectors static const (was rebuilt every call) - Keep only safe, verified semantically-neutral patterns Closes #5, Closes #6, Closes #7, Closes #10, Closes #12, Closes #13, Closes #15, Closes #16
sondt99
added a commit
that referenced
this pull request
Aug 10, 2026
Fix all remaining issues: CFF refactor, junkcode cleanup, naming, constants, func2rva
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive refactoring covering all remaining open issues (#5, #6, #7, #10, #12, #13, #15, #16).
obfuscatecff (#5)
using namespace asmjit;from header — all types now fully qualifiedZydisFormatter/ZydisDecoderfrom file-scope globals to class memberscreate_functionsvector byconst&(was copying entire vector)const auto&in loops (was copying each element)visited_rvasvector withunordered_set(O(1) vs O(n) lookup)consttoget_added_size()cfflattening (#6)
is_first_instruction— set totrueonpush_rax(was alwaysfalseafter CFF)find_ifforlast_inst(was UB whenend()returned)junkcode (#7, #16)
patch_junk_region()helperstd::cout << ""statementsstatic const(was rebuilt on every call)Naming (#10)
ctfflattening→cff_flatteningacross all files (typo fix)asmjit::prefix in REG_PAIR macrofunc2rva (#12)
display_function_table()methodstatic std::vector<FunctionInfo> empty_listwiththrowon uninitialized accessConstants (#15)
constants.hwith all named constants (PE, CFF, junk, PDB)Files Changed (11 files, +263 -308)
constants.hobfuscatecff.husing namespace, add members, const, namingobfuscatecff.cppcfflattening.cppjunkcode.hpatch_junk_regiondeclarationjunkcode.cppfunc2rva.hdisplay_function_tabledeclarationfunc2rva.cpppdbparser.hObfuGuard.vcxprojObfuGuard.vcxproj.filtersChecklist
using namespace asmjit;removed, all types qualifiedcreate_functionstakesconst std::vector&(no copy)visited_rvasusesunordered_set(O(1) lookup)is_first_instructionset correctly on new first instructionfind_ifresults checked before dereferencingpatch_junk_region()std::cout << ""removedstatic const(initialized once)ctfflattening→cff_flatteningeverywheredisplay_function_table()extracted, display code deduplicatedstatic empty_list→throw std::runtime_errorconstants.hcreated with named constantsTest plan
match_check.pyon full 60-binary test suiteCloses #5, Closes #6, Closes #7, Closes #10, Closes #12, Closes #13, Closes #15, Closes #16